]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
NetworkStatus: hide the only connection for wired devices
authorGiovanni Campagna <gcampagna@src.gnome.org>
Fri, 25 Mar 2011 16:12:38 +0000 (17:12 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Fri, 25 Mar 2011 19:58:37 +0000 (20:58 +0100)
For wired devices (actually, ethernet devices), hide the connection
list when there is only one connection (either automatic or stored).
The device can be operated with the associated switch.

js/ui/status/network.js

index 0bb38004f813a859ec6c6fb1fd16fd034fc39552..189af80048186d15874f7ad9351f355e8bb86263 100644 (file)
@@ -449,8 +449,10 @@ NMDevice.prototype = {
             obj.item.destroy();
         this._connections.splice(pos, 1);
 
-        if (this._connections.length == 0) {
+        if (this._connections.length <= 1) {
             // We need to show the automatic connection again
+            // (or in the case of NMDeviceWired, we want to hide
+            // the only explicit connection)
             this._clearSection();
             this._createSection();
         }
@@ -678,6 +680,20 @@ NMDeviceWired.prototype = {
         return true;
     },
 
+    _createSection: function() {
+        NMDevice.prototype._createSection.call(this);
+
+        // if we have only one connection (normal or automatic)
+        // we hide the connection list, and use the switch to control
+        // the device
+        // we can do it here because addConnection and removeConnection
+        // both call _createSection at some point
+        if (this._connections.length <= 1)
+            this.section.actor.hide();
+        else
+            this.section.actor.show();
+    },
+
     _createAutomaticConnection: function() {
         let connection = new NetworkManager.Connection();
         connection._uuid = NetworkManager.utils_uuid_generate();